package com.test.service;


import com.test.dao.EchartInfoDao;
import com.test.dao.StuOperatDao;
import com.test.entity.CompAllInfoDto;
import com.test.entity.StuAllInfoDto;
import org.omg.CORBA.Object;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class EchartInfoService {
    @Autowired
    private EchartInfoDao echartInfoDao;

    public int selectAllCompCount(){
        return echartInfoDao.selectAllCompCount();
    }


    public List<Map<Object,Object>> selectPieChart(){
        return echartInfoDao.selectPieChart();
    }


    public List<String> selectCompMap(){
        List<CompAllInfoDto> compMapList = echartInfoDao.selectCompMap();
        List<String> compMapListStr = new ArrayList<>();
        if(compMapList.size()>0){
            for(int i = 0 ;i<compMapList.size();i++){
               StringBuffer compAddress = new StringBuffer();
               String province =  compMapList.get(i).getComp_province();
               if(province!=null&&!"".equals(province)){
                   compAddress.append(province);
               }
               String city = compMapList.get(i).getComp_city();
                if(city!=null&&!"".equals(city)){
                    compAddress.append(city);
                }
                String county = compMapList.get(i).getComp_county();
                if(county!=null&&!"".equals(county)){
                    compAddress.append(county);
                }

                String address = compMapList.get(i).getComp_address();
                if(address!=null&&!"".equals(address)){
                    compAddress.append(address);
                }

                if (compAddress!=null&&!"".equals(compAddress)){
                    compMapListStr.add(compAddress.toString());
                }
            }
        }else{
            return null;
        }
        return compMapListStr;
    }

    public List<Map<String, java.lang.Object>> selectkindCount(){
        List<Map<String, java.lang.Object>>  resultList= echartInfoDao.selectkindCount();
        return resultList;
    }

    public List<Map<String, java.lang.Object>> selectBarCompNum(){
        List<Map<String, java.lang.Object>>  resultList= echartInfoDao.selectBarCompNum();
        return resultList;
    }
    public List<Map<java.lang.Object, java.lang.Object>> selectStuAttentKindPieChart(String u_acount){
        List<Map<java.lang.Object, java.lang.Object>>  resultList= echartInfoDao.selectStuAttentKindPieChart(u_acount);
        return resultList;
    }
}
